import Vue from 'vue'
import VueRouter from 'vue-router'
/* 电影界面 */
import FilmsView from '@/views/FilmsView/index.vue'
/* 正在热映 */
import NowPlaying from '@/views/FilmsView/NowPlaying.vue'
/* 即将上映 */
import ComingSoon from '@/views/FilmsView/ComingSoon.vue'
import NewsView from '@/views/NewsView.vue'
import CenterView from '@/views/CenterView.vue'

Vue.use(VueRouter)

const routes = [
    { // 电影
        path: '/films',
        // name: 'films',
        component: FilmsView,
        redirect: '/films/nowplaying',
        children: [
            { // 正在热映
                path: 'nowplaying',
                component: NowPlaying
            },
            { // 即将上映
                path: 'comingsoon',
                component: ComingSoon
            }
        ]
    },
    { // 影院
        path: '/cinemas',
        component: () => import(/* webpackChunkName: "cinemas" */ '@/views/CinemasView/index.vue')
    },
    { // 资讯
        path: '/news',
        component: NewsView
    },
    { // 我的
        path: '/center',
        component: CenterView
    },
    { // 电影详情
        path: '/film/:filmId',
        props: true, // 路由参数解耦 通过props传递路由参数
        component: () => import(/* webpackChunkName: "film" */ '@/views/FilmView/index.vue')
    },
    { // 城市列表
        path: '/cities',
        component: () => import(/* webpackChunkName: "cities" */ '@/views/CitiesView/index.vue')
    },
    { // 购票列表
        path: '/film/:filmId/cinemas',
        name: 'tickets',
        props: true,
        component: () => import(/* webpackChunkName: "tickets" */ '@/views/TicketsView/index.vue')
    },
    { // 影院信息(线下)
        path: '/cinema/:cinemaId',
        props: true,
        component: () => import(/* webpackChunkName: "cinema" */ '@/views/CinemaView/CinemaOffline.vue')
    },
    { // 影院信息(线上)
        // 路由匹配规则：https://github.com/vuejs/vue-router/blob/dev/examples/route-matching/app.js
        path: '/cinema/:cinemaId/film/:filmId?/:showDate?',
        props: true,
        component: () => import(/* webpackChunkName: "cinema" */ '@/views/CinemaView/index.vue')
    },
    {
        path: '*',
        redirect: '/films/nowplaying'
    }
]

const router = new VueRouter({
    routes
})

export default router
